import type { ColumnType } from "ant-design-vue/es/table";

type TableInstance = {
  getData(data: any): void;
};

export default function useTable<T>(rawColumns: ColumnType<T>[]) {
  const tableRef = ref<TableInstance>();
  const columns = ref<ColumnType<T>[]>(rawColumns);

  function search(research = false) {
    tableRef.value?.getData(research);
  }

  return {
    tableRef,
    columns,
    search
  };
}
